<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title>ActiveRecord::ConnectionAdapters::Quoting</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <link rel="stylesheet" href="../../../css/reset.css" type="text/css" media="screen" />
<link rel="stylesheet" href="../../../css/main.css" type="text/css" media="screen" />
<link rel="stylesheet" href="../../../css/github.css" type="text/css" media="screen" />
<script src="../../../js/jquery-1.3.2.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../../js/jquery-effect.js" type="text/javascript" charset="utf-8"></script>
<script src="../../../js/main.js" type="text/javascript" charset="utf-8"></script>
<script src="../../../js/highlight.pack.js" type="text/javascript" charset="utf-8"></script>

</head>

<body>     
    <div class="banner">
        
            <span>Ruby on Rails v4.0.0</span><br />
        
        <h1>
            <span class="type">Module</span> 
            ActiveRecord::ConnectionAdapters::Quoting 
            
        </h1>
        <ul class="files">
            
            <li><a href="../../../files/activerecord/lib/active_record/connection_adapters/abstract/quoting_rb.html">activerecord/lib/active_record/connection_adapters/abstract/quoting.rb</a></li>
            
        </ul>
    </div>
    <div id="bodyContent">
        <div id="content">
  


  


  
  


  


  
    <!-- Method ref -->
    <div class="sectiontitle">Methods</div>
    <dl class="methods">
      
        <dt>Q</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="Quoting.html#method-i-quote">quote</a>,
              </li>
            
              
              <li>
                <a href="Quoting.html#method-i-quote_column_name">quote_column_name</a>,
              </li>
            
              
              <li>
                <a href="Quoting.html#method-i-quote_string">quote_string</a>,
              </li>
            
              
              <li>
                <a href="Quoting.html#method-i-quote_table_name">quote_table_name</a>,
              </li>
            
              
              <li>
                <a href="Quoting.html#method-i-quote_table_name_for_assignment">quote_table_name_for_assignment</a>,
              </li>
            
              
              <li>
                <a href="Quoting.html#method-i-quoted_date">quoted_date</a>,
              </li>
            
              
              <li>
                <a href="Quoting.html#method-i-quoted_false">quoted_false</a>,
              </li>
            
              
              <li>
                <a href="Quoting.html#method-i-quoted_true">quoted_true</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>T</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="Quoting.html#method-i-type_cast">type_cast</a>
              </li>
            
          </ul>
        </dd>
      
    </dl>
  

  



  

    

    

    


    


    <!-- Methods -->
        
      <div class="sectiontitle">Instance Public methods</div>
      
        <div class="method">
          <div class="title method-title" id="method-i-quote">
            
              <b>quote</b>(value, column = nil)
            
            <a href="Quoting.html#method-i-quote" name="method-i-quote" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Quotes the column value to help prevent <a
href="http://en.wikipedia.org/wiki/SQL_injection">SQL injection
attacks</a>.</p>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-quote_source')" id="l_method-i-quote_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/afd4a14332c49fa0e236e6904a5f7e09ce33c407/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb#L8" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-quote_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activerecord/lib/active_record/connection_adapters/abstract/quoting.rb, line 8</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">quote</span>(<span class="ruby-identifier">value</span>, <span class="ruby-identifier">column</span> = <span class="ruby-keyword">nil</span>)
  <span class="ruby-comment"># records are quoted as their primary key</span>
  <span class="ruby-keyword">return</span> <span class="ruby-identifier">value</span>.<span class="ruby-identifier">quoted_id</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">value</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-value">:quoted_id</span>)

  <span class="ruby-keyword">case</span> <span class="ruby-identifier">value</span>
  <span class="ruby-keyword">when</span> <span class="ruby-constant">String</span>, <span class="ruby-constant">ActiveSupport</span><span class="ruby-operator">::</span><span class="ruby-constant">Multibyte</span><span class="ruby-operator">::</span><span class="ruby-constant">Chars</span>
    <span class="ruby-identifier">value</span> = <span class="ruby-identifier">value</span>.<span class="ruby-identifier">to_s</span>
    <span class="ruby-keyword">return</span> <span class="ruby-node">&quot;'#{quote_string(value)}'&quot;</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">column</span>

    <span class="ruby-keyword">case</span> <span class="ruby-identifier">column</span>.<span class="ruby-identifier">type</span>
    <span class="ruby-keyword">when</span> <span class="ruby-value">:binary</span> <span class="ruby-keyword">then</span> <span class="ruby-node">&quot;'#{quote_string(column.string_to_binary(value))}'&quot;</span>
    <span class="ruby-keyword">when</span> <span class="ruby-value">:integer</span> <span class="ruby-keyword">then</span> <span class="ruby-identifier">value</span>.<span class="ruby-identifier">to_i</span>.<span class="ruby-identifier">to_s</span>
    <span class="ruby-keyword">when</span> <span class="ruby-value">:float</span> <span class="ruby-keyword">then</span> <span class="ruby-identifier">value</span>.<span class="ruby-identifier">to_f</span>.<span class="ruby-identifier">to_s</span>
    <span class="ruby-keyword">else</span>
      <span class="ruby-node">&quot;'#{quote_string(value)}'&quot;</span>
    <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">when</span> <span class="ruby-keyword">true</span>, <span class="ruby-keyword">false</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">column</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">column</span>.<span class="ruby-identifier">type</span> <span class="ruby-operator">==</span> <span class="ruby-value">:integer</span>
      <span class="ruby-identifier">value</span> <span class="ruby-operator">?</span> <span class="ruby-string">'1'</span> <span class="ruby-operator">:</span> <span class="ruby-string">'0'</span>
    <span class="ruby-keyword">else</span>
      <span class="ruby-identifier">value</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">quoted_true</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">quoted_false</span>
    <span class="ruby-keyword">end</span>
    <span class="ruby-comment"># BigDecimals need to be put in a non-normalized form and quoted.</span>
  <span class="ruby-keyword">when</span> <span class="ruby-keyword">nil</span>        <span class="ruby-keyword">then</span> <span class="ruby-string">&quot;NULL&quot;</span>
  <span class="ruby-keyword">when</span> <span class="ruby-constant">BigDecimal</span> <span class="ruby-keyword">then</span> <span class="ruby-identifier">value</span>.<span class="ruby-identifier">to_s</span>(<span class="ruby-string">'F'</span>)
  <span class="ruby-keyword">when</span> <span class="ruby-constant">Numeric</span>, <span class="ruby-constant">ActiveSupport</span><span class="ruby-operator">::</span><span class="ruby-constant">Duration</span> <span class="ruby-keyword">then</span> <span class="ruby-identifier">value</span>.<span class="ruby-identifier">to_s</span>
  <span class="ruby-keyword">when</span> <span class="ruby-constant">Date</span>, <span class="ruby-constant">Time</span> <span class="ruby-keyword">then</span> <span class="ruby-node">&quot;'#{quoted_date(value)}'&quot;</span>
  <span class="ruby-keyword">when</span> <span class="ruby-constant">Symbol</span>     <span class="ruby-keyword">then</span> <span class="ruby-node">&quot;'#{quote_string(value.to_s)}'&quot;</span>
  <span class="ruby-keyword">when</span> <span class="ruby-constant">Class</span>      <span class="ruby-keyword">then</span> <span class="ruby-node">&quot;'#{value.to_s}'&quot;</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-node">&quot;'#{quote_string(YAML.dump(value))}'&quot;</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-quote_column_name">
            
              <b>quote_column_name</b>(column_name)
            
            <a href="Quoting.html#method-i-quote_column_name" name="method-i-quote_column_name" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Quotes the column name. Defaults to no quoting.</p>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-quote_column_name_source')" id="l_method-i-quote_column_name_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/afd4a14332c49fa0e236e6904a5f7e09ce33c407/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb#L87" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-quote_column_name_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activerecord/lib/active_record/connection_adapters/abstract/quoting.rb, line 87</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">quote_column_name</span>(<span class="ruby-identifier">column_name</span>)
  <span class="ruby-identifier">column_name</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-quote_string">
            
              <b>quote_string</b>(s)
            
            <a href="Quoting.html#method-i-quote_string" name="method-i-quote_string" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Quotes a string, escaping any ‘ (single quote) and \ (backslash)
characters.</p>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-quote_string_source')" id="l_method-i-quote_string_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/afd4a14332c49fa0e236e6904a5f7e09ce33c407/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb#L82" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-quote_string_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activerecord/lib/active_record/connection_adapters/abstract/quoting.rb, line 82</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">quote_string</span>(<span class="ruby-identifier">s</span>)
  <span class="ruby-identifier">s</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp">/\/</span>, <span class="ruby-string">'\&amp;\&amp;'</span>).<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp">/'/</span>, <span class="ruby-string">&quot;''&quot;</span>) <span class="ruby-comment"># ' (for ruby-mode)</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-quote_table_name">
            
              <b>quote_table_name</b>(table_name)
            
            <a href="Quoting.html#method-i-quote_table_name" name="method-i-quote_table_name" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Quotes the table name. Defaults to column name quoting.</p>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-quote_table_name_source')" id="l_method-i-quote_table_name_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/afd4a14332c49fa0e236e6904a5f7e09ce33c407/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb#L92" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-quote_table_name_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activerecord/lib/active_record/connection_adapters/abstract/quoting.rb, line 92</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">quote_table_name</span>(<span class="ruby-identifier">table_name</span>)
  <span class="ruby-identifier">quote_column_name</span>(<span class="ruby-identifier">table_name</span>)
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-quote_table_name_for_assignment">
            
              <b>quote_table_name_for_assignment</b>(table, attr)
            
            <a href="Quoting.html#method-i-quote_table_name_for_assignment" name="method-i-quote_table_name_for_assignment" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Override to return the quoted table name for assignment. Defaults to table
quoting.</p>

<p>This works for mysql and mysql2 where table.column can be used to resolve
ambiguity.</p>

<p>We override this in the sqlite and postgresql adapters to use only the
column name (as per syntax requirements).</p>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-quote_table_name_for_assignment_source')" id="l_method-i-quote_table_name_for_assignment_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/afd4a14332c49fa0e236e6904a5f7e09ce33c407/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb#L104" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-quote_table_name_for_assignment_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activerecord/lib/active_record/connection_adapters/abstract/quoting.rb, line 104</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">quote_table_name_for_assignment</span>(<span class="ruby-identifier">table</span>, <span class="ruby-identifier">attr</span>)
  <span class="ruby-identifier">quote_table_name</span>(<span class="ruby-node">&quot;#{table}.#{attr}&quot;</span>)
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-quoted_date">
            
              <b>quoted_date</b>(value)
            
            <a href="Quoting.html#method-i-quoted_date" name="method-i-quoted_date" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-quoted_date_source')" id="l_method-i-quoted_date_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/afd4a14332c49fa0e236e6904a5f7e09ce33c407/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb#L116" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-quoted_date_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activerecord/lib/active_record/connection_adapters/abstract/quoting.rb, line 116</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">quoted_date</span>(<span class="ruby-identifier">value</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">value</span>.<span class="ruby-identifier">acts_like?</span>(<span class="ruby-value">:time</span>)
    <span class="ruby-identifier">zone_conversion_method</span> = <span class="ruby-constant">ActiveRecord</span><span class="ruby-operator">::</span><span class="ruby-constant">Base</span>.<span class="ruby-identifier">default_timezone</span> <span class="ruby-operator">==</span> <span class="ruby-value">:utc</span> <span class="ruby-operator">?</span> <span class="ruby-value">:getutc</span> <span class="ruby-operator">:</span> <span class="ruby-value">:getlocal</span>

    <span class="ruby-keyword">if</span> <span class="ruby-identifier">value</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">zone_conversion_method</span>)
      <span class="ruby-identifier">value</span> = <span class="ruby-identifier">value</span>.<span class="ruby-identifier">send</span>(<span class="ruby-identifier">zone_conversion_method</span>)
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">value</span>.<span class="ruby-identifier">to_s</span>(<span class="ruby-value">:db</span>)
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-quoted_false">
            
              <b>quoted_false</b>()
            
            <a href="Quoting.html#method-i-quoted_false" name="method-i-quoted_false" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-quoted_false_source')" id="l_method-i-quoted_false_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/afd4a14332c49fa0e236e6904a5f7e09ce33c407/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb#L112" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-quoted_false_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activerecord/lib/active_record/connection_adapters/abstract/quoting.rb, line 112</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">quoted_false</span>
  <span class="ruby-string">&quot;'f'&quot;</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-quoted_true">
            
              <b>quoted_true</b>()
            
            <a href="Quoting.html#method-i-quoted_true" name="method-i-quoted_true" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-quoted_true_source')" id="l_method-i-quoted_true_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/afd4a14332c49fa0e236e6904a5f7e09ce33c407/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb#L108" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-quoted_true_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activerecord/lib/active_record/connection_adapters/abstract/quoting.rb, line 108</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">quoted_true</span>
  <span class="ruby-string">&quot;'t'&quot;</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-type_cast">
            
              <b>type_cast</b>(value, column)
            
            <a href="Quoting.html#method-i-type_cast" name="method-i-type_cast" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Cast a <code>value</code> to a type that the database understands. For
example, SQLite does not understand dates, so this method will convert a <a
href="../../Date.html">Date</a> to a <a
href="../../String.html">String</a>.</p>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-type_cast_source')" id="l_method-i-type_cast_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/afd4a14332c49fa0e236e6904a5f7e09ce33c407/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb#L46" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-type_cast_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activerecord/lib/active_record/connection_adapters/abstract/quoting.rb, line 46</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">type_cast</span>(<span class="ruby-identifier">value</span>, <span class="ruby-identifier">column</span>)
  <span class="ruby-keyword">return</span> <span class="ruby-identifier">value</span>.<span class="ruby-identifier">id</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">value</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-value">:quoted_id</span>)

  <span class="ruby-keyword">case</span> <span class="ruby-identifier">value</span>
  <span class="ruby-keyword">when</span> <span class="ruby-constant">String</span>, <span class="ruby-constant">ActiveSupport</span><span class="ruby-operator">::</span><span class="ruby-constant">Multibyte</span><span class="ruby-operator">::</span><span class="ruby-constant">Chars</span>
    <span class="ruby-identifier">value</span> = <span class="ruby-identifier">value</span>.<span class="ruby-identifier">to_s</span>
    <span class="ruby-keyword">return</span> <span class="ruby-identifier">value</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">column</span>

    <span class="ruby-keyword">case</span> <span class="ruby-identifier">column</span>.<span class="ruby-identifier">type</span>
    <span class="ruby-keyword">when</span> <span class="ruby-value">:binary</span> <span class="ruby-keyword">then</span> <span class="ruby-identifier">value</span>
    <span class="ruby-keyword">when</span> <span class="ruby-value">:integer</span> <span class="ruby-keyword">then</span> <span class="ruby-identifier">value</span>.<span class="ruby-identifier">to_i</span>
    <span class="ruby-keyword">when</span> <span class="ruby-value">:float</span> <span class="ruby-keyword">then</span> <span class="ruby-identifier">value</span>.<span class="ruby-identifier">to_f</span>
    <span class="ruby-keyword">else</span>
      <span class="ruby-identifier">value</span>
    <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">when</span> <span class="ruby-keyword">true</span>, <span class="ruby-keyword">false</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">column</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">column</span>.<span class="ruby-identifier">type</span> <span class="ruby-operator">==</span> <span class="ruby-value">:integer</span>
      <span class="ruby-identifier">value</span> <span class="ruby-operator">?</span> <span class="ruby-number">1</span> <span class="ruby-operator">:</span> <span class="ruby-number">0</span>
    <span class="ruby-keyword">else</span>
      <span class="ruby-identifier">value</span> <span class="ruby-operator">?</span> <span class="ruby-string">'t'</span> <span class="ruby-operator">:</span> <span class="ruby-string">'f'</span>
    <span class="ruby-keyword">end</span>
    <span class="ruby-comment"># BigDecimals need to be put in a non-normalized form and quoted.</span>
  <span class="ruby-keyword">when</span> <span class="ruby-keyword">nil</span>        <span class="ruby-keyword">then</span> <span class="ruby-keyword">nil</span>
  <span class="ruby-keyword">when</span> <span class="ruby-constant">BigDecimal</span> <span class="ruby-keyword">then</span> <span class="ruby-identifier">value</span>.<span class="ruby-identifier">to_s</span>(<span class="ruby-string">'F'</span>)
  <span class="ruby-keyword">when</span> <span class="ruby-constant">Numeric</span>    <span class="ruby-keyword">then</span> <span class="ruby-identifier">value</span>
  <span class="ruby-keyword">when</span> <span class="ruby-constant">Date</span>, <span class="ruby-constant">Time</span> <span class="ruby-keyword">then</span> <span class="ruby-identifier">quoted_date</span>(<span class="ruby-identifier">value</span>)
  <span class="ruby-keyword">when</span> <span class="ruby-constant">Symbol</span>     <span class="ruby-keyword">then</span> <span class="ruby-identifier">value</span>.<span class="ruby-identifier">to_s</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">to_type</span> = <span class="ruby-identifier">column</span> <span class="ruby-operator">?</span> <span class="ruby-node">&quot; to #{column.type}&quot;</span> <span class="ruby-operator">:</span> <span class="ruby-string">&quot;&quot;</span>
    <span class="ruby-identifier">raise</span> <span class="ruby-constant">TypeError</span>, <span class="ruby-node">&quot;can't cast #{value.class}#{to_type}&quot;</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
                    </div>

    </div>
  </body>
</html>    